package com.huawei.tree.threaded_binary_tree;

import java.util.Scanner;

//测试线索化二叉树
//创建一个二叉树
//                                       1:亚索
//                  2：诺手                                   3：盲僧
//         4：瑞文              5：腕豪               6：剑圣              7：螳螂
//    8:狗头    9：武器   10：凯南   11：纳尔     12：豹女  13：千珏    14：凯影    15：小丑
public class ThreadedBinaryTreeTest {
    public static void main(String[] args) {
        ThreadedBinaryTree threadedBinaryTree = new ThreadedBinaryTree();
        //创建需要的节点
        ThreadedHeroNode node1 = new ThreadedHeroNode(1,"亚索");
        ThreadedHeroNode node2 = new ThreadedHeroNode(2,"诺手");
        ThreadedHeroNode node3 = new ThreadedHeroNode(3,"盲僧");
        ThreadedHeroNode node4 = new ThreadedHeroNode(4,"瑞文");
        ThreadedHeroNode node5 = new ThreadedHeroNode(5,"腕豪");
        ThreadedHeroNode node6 = new ThreadedHeroNode(6,"剑圣");
        ThreadedHeroNode node7 = new ThreadedHeroNode(7,"螳螂");
        ThreadedHeroNode node8 = new ThreadedHeroNode(8,"狗头");
        ThreadedHeroNode node9 = new ThreadedHeroNode(9,"武器");
        ThreadedHeroNode node10 = new ThreadedHeroNode(10,"凯南");
        ThreadedHeroNode node11 = new ThreadedHeroNode(11,"纳尔");
        ThreadedHeroNode node12 = new ThreadedHeroNode(12,"豹女");
        ThreadedHeroNode node13 = new ThreadedHeroNode(13,"千珏");
        ThreadedHeroNode node14 = new ThreadedHeroNode(14,"凯影");
        ThreadedHeroNode node15 = new ThreadedHeroNode(15,"小丑");


        //手动创建二叉树，后边学习递归创建二叉树
        threadedBinaryTree.setRoot(node1);
        node1.setLeft(node2);
        node2.setLeft(node4);
        node2.setRight(node5);
        node1.setRight(node3);
        node3.setLeft(node6);
        node3.setRight(node7);
        node4.setLeft(node8);
        node4.setRight(node9);
        node5.setLeft(node10);
        node5.setRight(node11);
        node6.setLeft(node12);
        node6.setRight(node13);
        node7.setLeft(node14);
        node7.setRight(node15);

        System.out.println("请输入：");
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();

        if (i == 1) {
            threadedBinaryTree.preOrderThreadedNode();
            System.out.println("前序线索化：");
            System.out.println(node12);
            System.out.println("豹女前驱结点：" + node12.getLeft());
            System.out.println("豹女后继节点：" + node12.getRight());
            System.out.println(node13);
            System.out.println("千珏前驱结点：" + node13.getLeft());
            System.out.println("千珏后继节点：" + node13.getRight());
            System.out.println("##########");
        }else if (i == 2) {
            threadedBinaryTree.midOrderThreadedNodes();
            System.out.println("中序线索化：");
            System.out.println(node12);
            System.out.println("豹女前驱结点：" + node12.getLeft());
            System.out.println("豹女后继节点：" + node12.getRight());
            System.out.println(node13);
            System.out.println("千珏前驱结点：" + node13.getLeft());
            System.out.println("千珏后继节点：" + node13.getRight());
            System.out.println("##########");
        }else {
            threadedBinaryTree.afterOrderThreadedNode();
            System.out.println("后序线索化：");
            System.out.println(node12);
            System.out.println("豹女前驱结点：" + node12.getLeft());
            System.out.println("豹女后继节点：" + node12.getRight());
            System.out.println(node13);
            System.out.println("千珏前驱结点：" + node13.getLeft());
            System.out.println("千珏后继节点：" + node13.getRight());
            System.out.println("##########");
        }
    }
}
